import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: '/',
    redirect:'/main/menu'
  },
  {
    path: '/main',
    name: 'Main',
    component: () => import( '../views/Main.vue'),
    children:[
      {
        path:'menu',
        name:'Menu',
        component: () => import( '../views/Menu.vue'),
        meta:{index:1}
      },
      {
        path:'order',
        name:'Order',
        component: () => import( '../views/Order.vue'),
        meta:{index:2,hasLogin:true}
      },
      {
        path:'category',
        name:'Category',
        component: () => import( '../views/Category.vue'),
        meta:{index:3}
      },
      {
        path:'user',
        name:'User',
        component: () => import( '../views/User.vue'),
        meta:{index:4}
      },
      

    ],
   
  },
  {
    path: '/searchFood',
    name: 'SearchFood',
    component:()=>import('../views/SearchFood.vue'), meta:{index:5}
  },
  {
    path: '/foodDetail',
    name: 'FoodDetail',
    component:()=>import('../views/FoodDetail.vue'), meta:{index:6}
  },
  {
    path: '/login',
    name: 'Login',
    component:()=>import('../views/Login.vue'), meta:{index:7}
  },
  {
    path: '/register',
    name: 'Register',
    component:()=>import('../views/Register.vue'), meta:{index:8}
  }
 
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

// 前置守卫
router.beforeEach((to,form,next)=>{
  
})

export default router
